DEFine PROCedure

Syntax: DEFine PROCedure name [(item {,item} )]
Location: QL ROM

The syntax of the SuperBASIC procedure can take two forms:

DEFine PROCedure name [(item {,item} )]: statement {:statement}: END DEFine

or 

DEFine PROCedure name [(item {,item} )]
{LOCal var {,var} }
{statements}
[RETurn]
END DEFine [name]

Parameters and items are treated in the same manner as with DEFine FuNction. However, please note that calling parameters should  not appear in brackets after the name (unless you intend to pass them otherwise than by reference!).

When called, all of the SuperBASIC code within the definition block will be executed until either an END DEFine or RETurn is found, in which case execution will is no need for a PROCedure definition block to contain a RETurn statement.

Strictly a PROCedure cannot return a value - however due to the nature of the parameters being passed by reference (see DEFine FuNction), this is possible.

Example:
A simple demonstration program which highlights the fact that a PROCedure or FuNction can actually be recursive (ie. call itself), and also highlights the effect of passing parameters by reference - keep an eye on the values in #0:

100 radius=50:height=125:CLS:CLS#0
110 Rndom_circle radius,(height),100
120 AT #0,0,0:PRINT#0,radius,height,100
130 DEFine PROCedure Rndom_circle (x,y,z)
140   INK RND(7):FILL RND(1)
150   CIRCLE RND (y),RND(z),x
160   FILL 0
170   AT #0,0,0:PRINT#0,x,y,z:PAUSE
180   x=x-RND(5):y=y-1:z=z+1
190   IF x<1:RETurn
200   Rndom_circle (x),y,z
210 END DEFine

WARNING:
As with DEFine FuNction problems do exist with recursive PROCedures which prevent the Break key from working.

CROSS-REFERENCE: 
Please see DEFine FuNction!
